home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 11 - 1995 / 11.02 Feb 95 / Yenta / C Libraries / MathTools.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-04-04  |  876 b   |  32 lines  |  [TEXT/KAHL]

  1.  
  2. #pragma once
  3.  
  4. /*=======================================================================*/
  5. /*=== This file contains a set of utilities for doing nifty math stuff ==*/
  6. /*=======================================================================*/
  7.  
  8. #ifdef __cplusplus
  9. extern "C" {
  10. #endif
  11.  
  12.     #define        IN_RANGE( x, lo, hi) ((x >= lo) && (x <= hi))
  13.     #define        PINTORANGE(x, lo, hi) ((IN_RANGE(x, lo, hi) ? x : (x < lo) ? lo : hi))
  14.     #define        Max(x, y)        ((x) > (y) ? (x) : (y))
  15.     #define        Min(x, y)        ((x) < (y) ? (x) : (y))
  16.     #define        SIGN(x) ((x > 0) ? 1 : -1)
  17.     #define        ODD(x)    (ceil(x/2.0) != (x/2))
  18.     #define        EVEN(x)    (ceil(x/2.0) == (x/2))
  19.  
  20.     int ReturnEven (int TheInt);    
  21.     /* return TheInt (if even) or TheInt+1 (if odd) */
  22.     
  23.     Boolean odd (long theval);
  24.     /* return true if theVal is odd */
  25.     
  26.     Boolean even (long theval);
  27.     /* return true if theVal is even */
  28.  
  29. #ifdef __cplusplus
  30. }
  31. #endif
  32.